package com.common.client;

import java.util.HashMap;

import com.smartgwt.client.widgets.Canvas;

public class CardLayoutCanvas extends Canvas {
	protected HashMap<Object, Canvas> cards = null;
	protected Canvas currentCard = null;

	public CardLayoutCanvas() {
		cards = new HashMap<Object, Canvas>();
	}

	public void addCard(Object key, Canvas card) {
		card.setWidth("100%");
		card.setHeight("100%");
		card.setPageLeft(0);
		card.setPageTop(0);
		this.addChild(card);
		cards.put(key, card);
		currentCard = card;
	}

	public void showCard(Object key) {
		for (Object _key : cards.keySet()) {
			Canvas c = cards.get(_key);
			if (key.equals(_key)) {
				c.show();
				currentCard = c;
			} else {
				c.hide();
			}
		}
	}

	/**
	 * @return the currentCard
	 */
	public Canvas getCurrentCard() {
		return currentCard;
	}

	/*
	 * //Issue: show() draws all cards when it should only draw the shown card
	 * 
	 * @Override public void show() {
	 * 
	 * }
	 */
}
